//
//  RwdStatusModel.swift
//  Weibo_rwd
//
//  Created by 任文迪 on 16/7/13.
//  Copyright © 2016年 spaceX. All rights reserved.
//

import UIKit

class RwdStatusModel: NSObject {
    
    //  发布微博时间
    var created_at: String?
    //  微博id
    var id: Int64 = 0
    //  微博内容
    var text: String?
    //  来源
    var source: String?
    //  用户信息
    var user:RwdUserModel?
    
    var retweeted_status:RwdStatusModel?	//被转发的原微博信息字段，当该微博为转发微博时返回 详细
    var reposts_count:Int = 0	//转发数
    var comments_count:Int = 0	//评论数
    var attitudes_count:Int	= 0 //表态数
    //  配图信息
    var pic_urls: [RwdStatusImageModel]?
    
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
        
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user"{
            
            guard let dict = value as? [String:AnyObject] else {
                
                return
                
            }
            user = RwdUserModel(dict: dict)

        }else if key == "retweeted_status" {
            
            guard let dict = value as? [String:AnyObject] else {
                
                return
                
            }
            retweeted_status = RwdStatusModel(dict: dict)
            
        }else if key == "pic_urls" {
            
            guard let dictArray = value as?[[String:AnyObject]] else {
                
                return
            }
            var temArray = [RwdStatusImageModel]()
            
            for dict in dictArray {
                
                let pictureInfos = RwdStatusImageModel(dict: dict)
                temArray.append(pictureInfos)
            }
            pic_urls = temArray
        }
        else {
            
             super.setValue(value, forKey: key)
            
        }
    
        
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
        
    }
    
}
